//
//  @ Project : Galaxy Star Trading System
//  @ File Name : MsgBuffer.h
//  @ Date : 2014/9/5
//  @ Author :
//
//


#if !defined(_CMSGBUFFER_H_H)
#define _CMSGBUFFER_H_H

namespace GSTrader
{
	namespace TradeStrategy
	{
		class CMsgBus;
		class CPortfolioPosition;

		class CMsgBuffer
		{
		public:
			CMsgBuffer(CFramework* pFramework, CMsgBus* pMsgBus);
			virtual ~CMsgBuffer();

			void OnMsg(CMsg* pMsg);
			void OnClear();
			void PopMsg();

			void OnNewOrder(COrder* pOrder, bool bQueue);
			void OnOrderDone(COrder* pOrder, bool bQueue);
			void OnOrderCanceled(COrder* pOrder, bool bQueue);
			void OnOrderTraded(COrder* pOrder, bool bQueue);
			void OnOrderPartTraded(COrder* pOrder, bool bQueue);
			void OnOrderFailed(COrder* pOrder, bool bQueue);
			void OnCancelOrderFailed(COrder* pOrder, bool bQueue);

			void OnNewReplaceOrder(CReplaceOrder* pReplaceOrder, bool bQueue);
			void OnReplaceOrderCanceled(COrder* pOrder, bool bQueue);
			void OnReplaceSendNewOrder(COrder* pOrder, bool bQueue);

			void OnTrade(CExecutionReport* pReport, bool bQueue);
			void OnNewMarketData(CMsg* pMsg, bool bQueue);

			void OnOrderStatusChange(CExecutionReport* pReport, bool bQueue);
			void OnPendingNewOrder(COrder* pOrder, bool bQueue);
			void OnTransaction(CTransaction* pTransaction, bool bQueue);
			void OnPositionOpen(CPortfolioPosition* pPosition, bool bQueue);
			void OnPositionChange(CPortfolioPosition* pPosition, bool bQueue);
			void OnPositionClose(CPortfolioPosition* pPosition, bool bQueue);
		private:
			CMsgBus*	m_pMsgBus;
			CFramework* m_pFramework;
			CMsgQueue*	m_pMsgQueue;
		};
	}
}

#endif //_CMSGBUFFER_H_H